%Find Optimal q under SB (``second best")
%Calculate second best solution (absent screening moral hazard) for a given
%q and iterate over q

qGrid=300;
qSpace=linspace(0,qBar,qGrid);

for z=1:qGrid
    
    q=qSpace(z);
    
    SB;
    vF(z)=FB-0.5*kappa*q^2;
    
    
end

[m,ind]=max(vF);
FSB=m;
qSB=qSpace(ind);
q=qSB;
SB;

tauSB=1/(Lambda-aB-qSB);
betaSB=betaB;